<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/layouts/template.xhtml">
	<ui:define name="body">
		<h:form id="form" acceptcharset="ISO-8859-1">

			<f:metadata>
				<f:viewParam name="param" value="#{releasedProductionsBean.param}" />
			</f:metadata>

			<p:panel header="#{msgs['massai.productionLaunch.header.register']}">
				<fieldset>
					<legend><h:outputText value="#{msgs['massai.productionLaunch.dataSpreadsheet']}" /></legend>

					<h:panelGrid columns="6">
						<h:panelGrid>
							<h:outputLabel value="#{msgs['massai.productionLaunch.code']}" for="code" />
							<p:inputText value="#{releasedProductionsBean.completedZerosLeft(releasedProductionsBean.spreadsheet.id, 6)}" 
								id="code" label="#{msgs['massai.productionLaunch.code']}" style="width: 80px; text-align: right;"
								disabled="true" readonly="true" />
						</h:panelGrid>

						<h:panelGrid>
							<h:outputLabel value="#{msgs['massai.productionLaunch.accrualBasis']}" for="accrualBasis" />
							<p:inputMask mask="99/9999" value="#{releasedProductionsBean.spreadsheet.accrualBasis}" 
								id="accrualBasis" label="#{msgs['massai.productionLaunch.accrualBasis']}" 
								style="width: 80px; text-align: right;" disabled="true" readonly="true"
								converter="accrualBasisConverter" />
						</h:panelGrid>

						<h:panelGrid>
							<h:outputLabel value="#{msgs['massai.productionLaunch.dateRegister']}" for="date" />
							<p:inputText value="#{releasedProductionsBean.spreadsheet.dateRegister}" 
								id="date" label="#{msgs['massai.productionLaunch.dateRegister']}" 
								style="width: 100px; text-align: right;" disabled="true" readonly="true">
								<f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
							</p:inputText>
						</h:panelGrid>

						<h:panelGrid>
							<h:outputLabel value="#{msgs['massai.productionLaunch.flow']}" for="flow" />
							<p:inputText value="#{releasedProductionsBean.spreadsheet.flow.description}" 
								id="flow" label="#{msgs['massai.productionLaunch.flow']}" 
								style="width: 104px;" disabled="true" readonly="true" />
						</h:panelGrid>

						<h:panelGrid>
							<h:outputLabel value="#{msgs['massai.productionLaunch.typePayroll']}" for="typePayroll" />
							<p:inputText value="#{releasedProductionsBean.spreadsheet.typePayroll.typePayroll}" 
								id="typePayroll" label="#{msgs['massai.productionLaunch.typePayroll']}" 
								maxlength="10" style="width: 100px;" disabled="true" readonly="true" />
						</h:panelGrid>

						<h:panelGrid>
							<h:outputLabel value="#{msgs['massai.productionLaunch.department']}" for="department" />
							<p:inputText
								value="#{releasedProductionsBean.spreadsheet.department.codeEmp} - #{releasedProductionsBean.spreadsheet.department.codeDepartment} - #{releasedProductionsBean.spreadsheet.department.alternativeName}" 
								id="department" label="#{msgs['massai.productionLaunch.department']}" 
								style="width: 300px;" disabled="true" readonly="true" />
						</h:panelGrid>
					</h:panelGrid>
					
					<h:panelGrid>
						<h:panelGrid>
							<h:outputLabel value="#{msgs['massai.productionLaunch.observation']}" for="observation" />
							<p:inputTextarea value="#{releasedProductionsBean.spreadsheet.observation}" 
								id="observation" label="#{msgs['massai.productionLaunch.observation']}" 
								disabled="true" readonly="true" rows="2" cols="120"/>
						</h:panelGrid>
					</h:panelGrid>

					<h:panelGrid>
						<h:panelGrid>
							<h:outputLabel value="#{msgs['massai.productionLaunch.observationRevision']}" for="observationAnalyze" />
							<p:inputTextarea 
								value="#{releasedProductionsBean.spreadsheet.observationAnalysis}" 
								id="observationAnalyze" label="#{msgs['massai.productionLaunch.observationRevision']}" 
								rows="2" cols="120" disabled="#{releasedProductionsBean.checkBlockedDepartment()}" 
								readonly="#{releasedProductionsBean.checkBlockedDepartment()}">
							</p:inputTextarea>
						</h:panelGrid>
					</h:panelGrid>

					<p:spacer height="20px" />

					<h:panelGrid style="width: 100%;">
						<h:panelGrid style="float: right;" columns="4">
							<p:commandButton value="#{msgs['common.back']}" style="padding: 1px !important;"
								action="releasedProductionsConsult" ajax="false" immediate="true"
								onclick="this.form.target='_self'" />

							<h:panelGroup rendered="#{sessionBean.showAction('productionReleasedProductions', 'printout') and releasedProductionsBean.spreadsheet.id ne null}">
								<h:form target="_blank">
									<p:commandButton tabindex="6" value="#{msgs['common.printout']}"
										actionListener="#{releasedProductionsBean.printout()}" ajax="false" 
										style="margin-right: 5px;"
										onclick="this.form.target='_blank'" />
								</h:form>
							</h:panelGroup>

							<p:commandButton value="#{msgs['common.revision']}"
								actionListener="#{releasedProductionsBean.revisionSpreadsheet()}" ajax="false" 
								style="margin-right: 5px;" styleClass="buttonNew" update=":form" 
								rendered="#{releasedProductionsBean.spreadsheetAproved}"
								onclick="this.form.target='_self'"  />

							<p:commandButton value="#{msgs['common.aproved']}"
								actionListener="#{releasedProductionsBean.aprovedSpreadsheet()}" ajax="true" 
								style="margin-right: 5px;" styleClass="buttonSave" update=":form"
								rendered="#{releasedProductionsBean.spreadsheetAproved}"
								onclick="this.form.target='_self'"  />
						</h:panelGrid>
					</h:panelGrid>
				</fieldset>

				<p:spacer height="25px" />

				<fieldset>
					<legend><h:outputText value="#{msgs['massai.productionLaunch.releases']}" /></legend>

					<ui:repeat var="entry" value="#{releasedProductionsBean.entriesLaunched}">
						<h:panelGroup id="dataTableLaunched">
							<p:spacer height="20px" />

							<h:panelGrid>
								<p:outputLabel value="#{entry.regime.regime}" style="text-transform: uppercase;" />

								<h:panelGroup>
									<p:outputLabel value="#{msgs['massai.productionLaunch.code']}: " />
									<h:outputText value="#{entry.employee.epgCodigo} - #{entry.employee.cargo}" />
								</h:panelGroup>

								<h:panelGroup>
									<p:outputLabel value="#{msgs['massai.productionLaunch.employee']}: " />
									<p:outputLabel value="#{entry.employee.nome}" />
								</h:panelGroup>
							</h:panelGrid>

							<p:dataTable var="item" value="#{entry.entryItems}" rowIndexVar="row">
								<p:column headerText="#{msgs['massai.productionLaunch.service']}">
									<h:outputText value="#{item.groupItem.serviceItem.description}" />
								</p:column>

								<p:column headerText="#{msgs['massai.productionLaunch.unitMeasure']}" width="90">
									<h:outputText value="#{item.groupItem.serviceItem.unitMeasure.acronym} - #{item.groupItem.serviceItem.unitMeasure.nameMeasure}" />
								</p:column>

								<p:column headerText="#{msgs['massai.productionLaunch.unitValue']}" width="90">
									<h:outputText value="#{item.unitPrice}">
										<f:convertNumber pattern="#,##0.00" maxFractionDigits="2" minFractionDigits="2" type="currency" />
									</h:outputText>
								</p:column>

								<p:column headerText="#{msgs['massai.productionLaunch.quantity']}" width="80">
									<h:outputText value="#{item.quantity}">
										<f:convertNumber pattern="#,##0.00" maxFractionDigits="2" minFractionDigits="2" type="number" />
									</h:outputText>
								</p:column>

								<p:column headerText="#{msgs['massai.productionLaunch.totalValue']}" width="90">
									<h:outputText value="#{item.totalValue}">
										<f:convertNumber pattern="#,##0.00" maxFractionDigits="2" minFractionDigits="2" type="currency" />
									</h:outputText>
								</p:column>
	
								<p:column headerText="#{msgs['massai.productionLaunch.percentageValue']}" width="100">
									<h:outputText value="#{item.valuePercentage}">
										<f:convertNumber pattern="#,##0.0000" maxFractionDigits="4" minFractionDigits="4" type="number" />
									</h:outputText>
								</p:column>
	
								<p:column headerText="#{msgs['massai.productionLaunch.budgetItem']}" width="110">
									<h:outputText value="#{item.budgetItem.cdReferencia}" />
								</p:column>
	
								<p:column headerText="#{msgs['massai.productionLaunch.observation']}">
									<h:outputText value="#{item.observation}" />
								</p:column>
	
								<p:columnGroup type="footer">
						            <p:row>
						                <p:column colspan="4" style="text-align:right" footerText="#{msgs['massai.productionLaunch.totals']}" />
						                <p:column footerText="#{releasedProductionsBean.decimalFormat('R$ #,##0.00', entry.totalAmount)}" />
						                <p:column style="text-align: left" footerText="#{releasedProductionsBean.decimalFormat('#,##0.0000', entry.totalPercentage)} %" />
						                <p:column colspan="2" />
						            </p:row>
						        </p:columnGroup>
							</p:dataTable>
						</h:panelGroup>
					</ui:repeat>
					
					<p:spacer height="15px" />
				</fieldset>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>
</html>